---
category: Layout
created: '2019-11-17'
description: Create same height columns with CSS flexbox
keywords: css flexbox, css layout, css same height columns
thumbnail: /assets/css-layout/thumbnails/same-height-columns.png
title: Same height columns
---

## HTML

```html index.html
<div class="same-height-columns">
    <!-- Column -->
    <div class="same-height-columns__column">
        <!-- Cover -->
        ...

        <!-- Content -->
        <div class="same-height-columns__content">...</div>

        <!-- Button sticks to the bottom -->
        ...
    </div>

    <!-- Repeat with other columns -->
    ...
</div>
```

## CSS

```css styles.css
.same-height-columns {
    display: flex;
}

.same-height-columns__column {
    flex: 1;
    /* Space between columns */
    margin: 0 8px;

    /* Layout each column */
    display: flex;
    flex-direction: column;
}

.same-height-columns__content {
    /* Take available height */
    flex: 1;
}
```

<Playground>
```css placeholders.css hidden
.lines {
    padding: 0.25rem 0;
    width: 100%;
    align-items: center;
    display: flex;
    justify-content: center;
    flex-direction: column;
}
.line {
    background: #d1d5db;
    height: 1px;
    margin-bottom: 0.25rem;
}
.line.line--20 {
    width: 20%;
}
.line.line--40 {
    width: 40%;
}
.line.line--60 {
    width: 60%;
}
.line.line--80 {
    width: 80%;
}
.line.line--100 {
    width: 100%;
}
```

```css styles.css hidden
body {
    height: 24rem;
}

.same-height-columns {
    display: flex;

    /* Demo */
    width: 100%;
    height: 100%;
}

.same-height-columns__column {
    flex: 1;
    /* Space between columns */
    margin: 0 0.25rem;

    /* Layout each column */
    display: flex;
    flex-direction: column;

    /* Demo */
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    padding: 0.25rem;
}

.same-height-columns__content {
    /* Take available height */
    flex: 1;
}
```

```html index.html hidden
<div class="same-height-columns">
    <div class="same-height-columns__column">
        <div class="rectangle rectangle--hor rectangle--md rectangle--100"></div>
        <div class="same-height-columns__content">
            <div class="lines">
                <div class="line line--20"></div>
                <div class="line line--80"></div>
                <div class="line line--40"></div>
                <div class="line line--60"></div>
                <div class="line line--20"></div>
            </div>
        </div>
        <div class="rectangle rectangle--hor rectangle--sm rectangle--100"></div>
    </div>

    <div class="same-height-columns__column">
        <div class="rectangle rectangle--hor rectangle--md rectangle--100"></div>
        <div class="same-height-columns__content">
            <div class="lines">
                <div class="line line--20"></div>
                <div class="line line--80"></div>
                <div class="line line--40"></div>
                <div class="line line--60"></div>
                <div class="line line--20"></div>

                <div class="line line--20"></div>
                <div class="line line--80"></div>
                <div class="line line--40"></div>
                <div class="line line--60"></div>
                <div class="line line--20"></div>
            </div>
        </div>
        <div class="rectangle rectangle--hor rectangle--sm rectangle--100"></div>
    </div>

    <div class="same-height-columns__column">
        <div class="rectangle rectangle--hor rectangle--md rectangle--100"></div>
        <div class="same-height-columns__content">
            <div class="lines">
                <div class="line line--20"></div>
                <div class="line line--80"></div>
                <div class="line line--40"></div>
                <div class="line line--60"></div>
                <div class="line line--20"></div>
            </div>
        </div>
        <div class="rectangle rectangle--hor rectangle--sm rectangle--100"></div>
    </div>
</div>
```
</Playground>
